Skip to content

Issue 1601 - Implement check mesh resolution#1630

Open
lsawade wants to merge 10 commits intodevelfrom
issue-1601-squash-merge
Open

Issue 1601 - Implement check mesh resolution#1630
lsawade wants to merge 10 commits intodevelfrom
issue-1601-squash-merge

Conversation

@lsawade
Copy link
Collaborator

@lsawade lsawade commented Feb 3, 2026

Description

Implements the computation of the mesh characteristic properties using for_all loop over all GLL points and a scatterview that is required to store and access element-wise reductions. Implemented as a unified struct for both 2 and 3D, specfem::assembly::Info<dimension_tag> without specialization of the struct, but specialization of some of the methods under the hood.

Info Constructor Description:

The Info struct constructor unifies 2D and 3D mesh resolution analysis into a single templated definition. The constructor operates in two phases:

  1. Element Processing Phase: Calls process_medium_elements<Dimension, Medium, Property>() for each medium/property combination in the assembly. This function uses a chunked domain iterator to traverse all GLL points, computing and reducing:
    - Material properties (vp, vs, rho) min/max
    - Domain bounding box coordinates
    - Element sizes (corner-to-corner distances)
    - GLL point spacing

Results are accumulated into an InfoScatters struct that holds all scatter reducers, including per-element views for velocity and distance bounds.
2. Derived Quantities Phase: A second parallel loop over elements computes the suggested timestep (from CFL condition using minimum GLL spacing and maximum velocity) and the largest minimum resolvable period (from average GLL spacing and minimum velocity).
These per-element values are reduced to obtain global bounds.

The InfoScatters struct uses dimension-templated ScatterMinMax views, allowing the bounding box reducer to be n-dimensional while scalar properties use 1D reductions.

Other necessary implementations

  • Implements load_on_device for global_coordinates
  • implements specfem::point::global_coordinates.coordinates() method which returns a view
  • Moves mesh_entities::element.ngll member to public
  • adds data_access type for global_coordinates
  • adds vmin, vmax member functions for the different media adds tests for these
  • adds point index copy constructor
  • adds tests for scatterminmax struct
  • adds tests for info computations (suggested dt etc.)
Squashed history
commit 1bcfcac4c3b88ff2a84e16715a216652bf905dfb
    Added 3D support

commit a0c2e1e4c632dfc318548bc3033160b2b5b97807
    Updated the code fully to be fully templated.

commit cc56d3d8edf5690d6ee08defb1ea982e5a68006c
    Updated the bounding box to use a registerarray

commit 535150ac4c6f9adad7e4dca927ebf57dc661bc14
    Updated the tests to match upstream fix

commit 3754efc1810817030e9f5566b7b3185916da548a
    Added ScatterMinMax struct for simpler interface of scatter reduction

commit 23c31ee6c9835b1d4d2a3ef69755b984dab01ba4
    Split out the core functions and tested them

commit 444cc8202a0766a55a0f7a519ea9eef59f92cd75
    Merge branch 'devel' into issue-1601

commit 94052e37ac2bfd6423ea65f21878627514dffd69
    Added all the missing files

commit 868eebb1b3af9e85a418d6aaa9e2f911a0a66a26
    Created 2D Info version.

commit 1132f0b89b117643e0b963fadee0e677424501d5
    Added computation of GLL point properties.

Issue Number

Closes #1601

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • THE DOCUMENTATION BUILDS WITHOUT WARNINGS/ERRORS
  • I have added labels to the PR (see right hand side of the PR page)
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

commit 1bcfcac4c3b88ff2a84e16715a216652bf905dfb
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Tue Feb 3 16:03:44 2026 -0500

    Added 3D support

commit a0c2e1e4c632dfc318548bc3033160b2b5b97807
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Tue Feb 3 15:32:18 2026 -0500

    Updated the code fully to be fully templated.

commit cc56d3d8edf5690d6ee08defb1ea982e5a68006c
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Tue Feb 3 10:47:44 2026 -0500

    Updated the boundaing box to use a registerarray

commit 535150a
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 14:21:29 2026 -0500

    Updated the tests to match upstream fix

commit 3754efc
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 08:41:19 2026 -0500

    Added ScatterMinMax struct for simpler interface of scatter reduction

commit 23c31ee
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 08:20:41 2026 -0500

    Split out the core functions and tested them

commit 444cc82
Merge: 94052e3 fc0558a
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 07:58:36 2026 -0500

    Merge branch 'devel' into issue-1601

commit 94052e3
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 07:57:35 2026 -0500

    Added all the missing files

commit 868eebb
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Mon Feb 2 07:54:15 2026 -0500

    Created 2D Info version.

commit 1132f0b
Author: Lucas Sawade <lsawade@princeton.edu>
Date:   Fri Jan 30 13:52:46 2026 -0500

    Added computation of GLL point properties.
@lsawade lsawade added the enhancement New feature or request label Feb 3, 2026
@lsawade lsawade requested review from Rohit-Kakodkar and icui and removed request for icui February 3, 2026 21:17
@lsawade lsawade marked this pull request as draft February 3, 2026 22:02
@lsawade lsawade marked this pull request as ready for review February 4, 2026 14:35
Copy link
Collaborator

@Rohit-Kakodkar Rohit-Kakodkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment.

this->edge_types, this->mesh };
this->fields = { this->mesh, this->element_types, simulation };

this->info = { *this };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pass different structs individually, similar to the functions we do above.

this->check_jacobian_matrix();


this->info = {*this};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants